//
//  WYGuessLikeController.m
//  Hangbag
//
//  Created by admin on 2018/2/11.
//  Copyright © 2018年 admin. All rights reserved.
//

#import "WYGuessLikeController.h"
#import "WYGuessLikeCell.h"
@interface WYGuessLikeController ()<UICollectionViewDelegate,UICollectionViewDataSource>

@property (nonatomic,strong)UICollectionView *collectionView;

@end

@implementation WYGuessLikeController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setupUI];
    self.view.backgroundColor = [UIColor whiteColor];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

-(void)setupUI
{
    
  //  self.collectionView.frame = CGRectMake(0, 0, kScreenWidth, kScreenHeight);
    UICollectionViewFlowLayout *layout=[[UICollectionViewFlowLayout alloc]init];
    layout.itemSize=CGSizeMake(100, 40);
    //横向最小距离
    layout.minimumInteritemSpacing=1.0f;
    layout.minimumLineSpacing=1.0f;
    //cell距离上  左  下 右 的距离
    layout.sectionInset=UIEdgeInsetsMake(0,6, 0, 6);
    [layout setScrollDirection:UICollectionViewScrollDirectionVertical];
    [layout setHeaderReferenceSize:CGSizeMake(kScreenWidth, 50)];
    self.collectionView = [[UICollectionView alloc]initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight) collectionViewLayout:layout];
    self.collectionView.delegate=self;
    self.collectionView.dataSource=self;
    
  //  [self.collectionView setCollectionViewLayout:layout];
    [self.collectionView registerNib:[UINib nibWithNibName:@"WYGuessLikeCell" bundle:nil] forCellWithReuseIdentifier:@"WYGuessLikeCell"];
    self.collectionView.showsHorizontalScrollIndicator = NO;
    self.collectionView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:self.collectionView];
    
}
-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
{
    return 1;
}
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return 4;
}
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    WYGuessLikeCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"WYGuessLikeCell" forIndexPath:indexPath];
    if (!cell) {
        cell = [[NSBundle mainBundle]loadNibNamed:@"WYGuessLikeCell" owner:nil options:nil].firstObject;
    }
    cell.backgroundColor = [UIColor redColor];
    return cell;

}

#pragma mark- collectionViewDatasource
- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section
{
    return 6.0f;
}
-(CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section
{
    return 6.0f;
}
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
    CGFloat itemWith =(kScreenWidth-24)/2;
    
    return CGSizeMake(itemWith, itemWith*1.4);
}











@end
